# -*- coding: utf-8 -*-
from abc import ABC
from app.views import CommonHandler
from app.configs import kj236_pool


class ReaderHandler(CommonHandler, ABC):
    async def get(self):
        sql = '''
            SELECT readerid, placement, isvalid 
            FROM m_reader 
            ORDER BY CAST(readerid AS INTEGER)
        '''
        readers, items = [], kj236_pool.select(sql)
        for item in items:
            if item[2]:
                readers.append({
                    'readerid': int(item[0]),
                    'regname': item[1]
                })
        await self.response(data=readers)
